<?php


namespace App\Http\Requests\Admin\Business;


use App\Http\Requests\BaseFormRequest;

class CardSchemeSaveFormRequest extends BaseFormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $id = $this->get('id', 0);
        return [
            'name' => [
                'required',
                'between:2,50'
            ],
            'terminal_quantity' => [
                'required',
                'regex:/[1-9]\d*/'
            ],
            'price' => [
                'required',
                'regex:/(^[1-9](\d*)?(\.\d{1,2})?$)|(^(0)$)|(^\d\.\d{1,2}?$)/'
            ]
        ];
    }

    public function attributes()
    {
        return [
            'name' => '卡名称',
            'terminal_quantity' => '终端数量',
            'price' => '单价',
        ];
    }
}